package com.cglib;


import net.sf.cglib.beans.BeanCopier;
import net.sf.cglib.core.Converter;
import net.sf.cglib.core.DebuggingClassWriter;

import com.basic.Dog;
import com.basic.DogWhite;
import com.basic.DogYellow;

public class BeanCopierTest {
	public static void main(String args[]) {
		System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY,
				"/tmp/1");
		BeanCopier copier = BeanCopier.create(Dog.class, DogYellow.class, true);
		Dog from = new Dog("dog1", 11);

		DogYellow to = new DogYellow();
		Converter converter = new DateIntConvert();
		copier.copy(from, to, converter); // 使用converter类

		System.out.println(to.getAge());
		
		
		BeanCopier copier2 = BeanCopier.create(Dog.class, DogWhite.class, true);
		DogWhite newto = new DogWhite();

		copier2.copy(from, newto, converter); // 使用converter类
		System.out.println(newto.getAge());


	}
}

